package com.wandian.ui.translation
{  import flash.text.*;
	
	public class TranslationAssetDescription extends Object
	{
		private var fAssetFontSize_num:Number;
		private var fAssetFont_str:String;
		private var fAssetXPos_num:Number;
		private var fAssetId_str:String;
		private var fAssetUrl_str:String;
		private var fIsHtmlText_bl:Boolean;
		private var fAssetText_str:String;
		private var fExternAssetDescription_obj:Object;
		private var fAssetYPos_num:Number;
		private var fAssetType_str:String;
		private var fAssetLetterSpacing_num:Number;
		private var fAssetLineSpacing_num:Number;
		public static const ASSET_TYPE_MOVIECLIP:String = "movieclip";
		public static const ASSET_TYPE_TEXT:String = "text";
		
		public function TranslationAssetDescription()
		{
			return;
		}// end function
		
		public function get assetFontSize() : Number
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetFontSize;
			}
			return this.fAssetFontSize_num;
		}// end function
		
		public function updateTextField(param1:TextField) : TextField
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.updateTextField(param1);
			}
			if (this.assetType != ASSET_TYPE_TEXT)
			{
				throw Error("Cannot update text field: asset has incompatible type");
			}
			param1.mouseWheelEnabled = false;
			param1.selectable = false;
			param1.autoSize = param1.defaultTextFormat.align != TextFormatAlign.JUSTIFY ? (param1.defaultTextFormat.align) : (TextFieldAutoSize.NONE);
			param1.embedFonts = true;
			param1.htmlText = this.assetText;
			param1.setTextFormat(this.updateTextFormat(param1.getTextFormat()));
			return param1;
		}// end function
		
		public function get assetType() : String
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetType;
			}
			return this.fAssetType_str;
		}// end function
		
		public function get assetLineSpacing() : Number
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetLineSpacing;
			}
			return this.fAssetLineSpacing_num;
		}// end function
		
		public function get externAssetDescription() : Object
		{
			return this.fExternAssetDescription_obj;
		}// end function
		
		public function initFromXMLDescription(param1:Object) : void
		{
			this.externAssetDescription = null;
			this.fAssetType_str = param1.type;
			this.fAssetId_str = param1.id;
			this.fAssetXPos_num = param1.x ? (Number(param1.x)) : (0);
			this.fAssetYPos_num = param1.y ? (Number(param1.y)) : (0);
			switch(this.assetType)
			{
				case ASSET_TYPE_TEXT:
				{
					this.fAssetText_str = param1.text;
					this.fAssetFont_str = param1.font;
					this.fAssetFontSize_num = Number(param1.size);
					this.fAssetLineSpacing_num = param1.linespacing ? (Number(param1.linespacing)) : (NaN);
					this.fAssetLetterSpacing_num = param1.letterspacing ? (Number(param1.letterspacing)) : (NaN);
					this.fIsHtmlText_bl = param1.htmlText == "true";
					break;
				}
				case ASSET_TYPE_MOVIECLIP:
				{
					this.fAssetUrl_str = param1.url;
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}// end function
		
		public function get assetUrl() : String
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetUrl;
			}
			return this.fAssetUrl_str;
		}// end function
		
		public function set externAssetDescription(param1:Object) : void
		{
			this.fExternAssetDescription_obj = param1;
			return;
		}// end function
		
		public function get assetX() : Number
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetX;
			}
			return this.fAssetXPos_num;
		}// end function
		
		public function get assetId() : String
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetId;
			}
			return this.fAssetId_str;
		}// end function
		
		public function get assetLetterSpacing() : Number
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetLetterSpacing;
			}
			return this.fAssetLetterSpacing_num;
		}// end function
		
		public function get assetY() : Number
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetY;
			}
			return this.fAssetYPos_num;
		}// end function
		
		public function get assetFont() : String
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetFont;
			}
			return this.fAssetFont_str;
		}// end function
		
		public function updateTextFormat(param1:TextFormat) : TextFormat
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.updateTextFormat(param1);
			}
			param1.size = this.assetFontSize ? (this.assetFontSize) : (param1.size);
			param1.font = this.assetFont ? (this.assetFont) : (param1.font);
			param1.leading = isNaN(this.assetLineSpacing) ? (param1.leading) : (this.assetLineSpacing);
			param1.letterSpacing = isNaN(this.assetLetterSpacing) ? (param1.letterSpacing) : (this.assetLetterSpacing);
			return param1;
		}// end function
		
		public function get assetText() : String
		{
			if (this.externAssetDescription)
			{
				return this.externAssetDescription.assetText;
			}
			return this.fAssetText_str;
		}// end function
		
		public function initFromExternAssetDescription(param1:Object) : void
		{
			this.externAssetDescription = param1;
			return;
		}// end function
		
	}
}
